unit JokerPawn;

interface

uses Pawn, Graphics, Types, Player;

type
 TJokerPawn = class(TPawn)
 private
  img: TBitmap;
 public
  function GetColor(InitColor: TColor): TColor; overload; override;
  procedure Draw(Canvas: TCanvas); override;
  constructor Create(Dim: integer);
  function IsTheSameColor(Other: TPawn): boolean; override;
 end;

implementation

function TJokerPawn.IsTheSameColor(Other: TPawn): Boolean;
begin
 Result := true;
end;

procedure TJokerPawn.Draw(Canvas: TCanvas);
var
 resizedBmp: TBitmap;
begin
 inherited  Draw(Canvas);
 
 resizedBmp := TBitmap.Create;
 resizedBmp.Width := Dimension;
 resizedBmp.Height := Dimension;
 resizedBmp.Canvas.StretchDraw(Rect(0,0,Dimension, Dimension), img);
 resizedBmp.TransparentColor := clFuchsia;
 resizedBmp.Transparent := true;

 DrawTransparency(Canvas, OldPosition.X,OldPosition.Y, resizedbmp, 0);
 resizedBmp.Free;
end;

constructor TJokerPawn.Create(Dim: integer);
begin
 inherited Create(Dim);
 Color := clBlack;
 
 img := TBitmap.Create;
 img.LoadFromFile('graph\joker.bmp');
end;

function TJokerPawn.GetColor(InitColor: TColor): TColor;
begin
 Result := InitColor;
end;

end.
